﻿using SQLDeploy.Data.Internal;
using SQLDeploy.Utils;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;


namespace SQLDeploy.Data.Deployment.Steps.Tasks
{
    public class SSISInstallTask : _FileBasedTask
    {
        public enum InstallLocationEnum : byte
        {
            SQLStore = 1,
            SSISStore = 2,
            FileSystem = 3
        }

        private InstallLocationEnum _installTo;
        private string _PackageName;
        private string _PackagePath;
        private string _ConfigFile;

        public SSISInstallTask(Step parentStep) : base(parentStep) { }

        public SSISInstallTask(Step parentStep, string name, string connectionName) :
            base(parentStep, name, connectionName) { }

        public SSISInstallTask(Step parentStep, string name, string connectionName, string PackageFile) :
            base(parentStep, name, connectionName, PackageFile) { }


        /**
         * Future use variables that can be used to perform on the fly modifications to SSIS package or config file,
         * prior to the package being installed.
        **/
        private ObservableCollection<Object> mConfigConModifications = new ObservableCollection<object>();
        private ObservableCollection<object> mPackageModifications = new ObservableCollection<object>();

        public string PackagePath
        {
            get { return _PackagePath; }
            set
            {
                Check.notNull(value);
                if (!Shared.DefaultStringComparer().Equals(value, _PackagePath))
                {
                    _PackagePath = value;
                    OnPropertyChanged("PackagePath");
                }
            }
        }

        public string PackageName
        {
            get { return _PackageName; }
            set
            {
                Check.notNullOrEmpty(value, "PackageName");
                if (!Shared.DefaultStringComparer().Equals(value, _PackageName))
                {
                    _PackageName = value;
                    OnPropertyChanged("PackageName");
                }
            }
        }

        public string PackageFile
        {
            get { return base.fileName; }
            set
            {
                base.fileName = value;
                OnPropertyChanged("PackageFile");
            }
        }

        public string ConfigFile
        {
            get { return _ConfigFile; }
            set
            {
                if (value != _ConfigFile)
                {
                    _ConfigFile = value;
                    OnPropertyChanged("ConfigFile");
                }
            }
        }

        public InstallLocationEnum InstallTo
        {
            get { return _installTo; }
            set
            {
                if (_installTo != value)
                {
                    _installTo = value;
                    OnPropertyChanged("InstallTo");
                }
            }
        }
        

    }
}
